/*
 * function TreeNode(x) {
 *   this.val = x;
 *   this.left = null;
 *   this.right = null;
 * }
 */

/**
  * 
  * @param root TreeNode类 
  * @param sum int整型 
  * @return bool布尔型
  */
 var path = []
 function hasPathSum( root ,  sum ) {
  // write code here
  if(root === null) return false
  path.push(root.val)
  sum -= root.val
  if(sum === 0 && root.left === null && root.right === null){
    return true
  }
  if(hasPathSum(root.left,sum)||hasPathSum(root.right,sum)){
    return true
  }
  path.pop()
}
module.exports = {
  hasPathSum : hasPathSum
};